﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Downplay.Mechanics.Impulses.Services;
using Orchard.Core.Contents;
using Orchard.Environment.Extensions;
using Orchard.ContentManagement;
using Downplay.Mechanics.Models;

namespace Downplay.Mechanics.Impulses.Defaults
{
    [OrchardFeature("Downplay.Mechanics.Impulses")]
    public class EditItemImpulseGenerator : IImpulseGenerator
    {

        public void Generating(ImpulseDisplayContext context)
        {
            var edit = new EditItemImpulse();
            var conn = (context.Content.As<ConnectorPart>());
            if (conn!=null)
            {
                edit.DisplayName = "Edit Connector";
            }
            // Return URL for detail view (i.e. front end)
            if (context.DisplayType == "Detail")
            {
                edit.IncludeReturnUrl = true;
            }
            context.Impulses.Add(edit);
        }

        public void Generated(ImpulseDisplayContext context)
        {
        }

        public void Actuating(ImpulseContext context)
        {
        }

        public void Actuated(ImpulseContext context)
        {
        }
    }
}